package com.demo.controller;

import com.demo.entity.Vo.DeathPatientVo;
import com.demo.entity.Vo.HighRiskPatientVo;
import com.demo.entity.Vo.IndicatorVteRiskVo;
import com.demo.entity.Vo.PatientMiddleHeightVo;
import com.demo.service.QualityControlService;
import com.demo.util.excle.UtilEasyExcle;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/excle")
@Api(tags = "表格导出")
public class QualityControlExcleController {
    @Autowired
    QualityControlService qualityControlService;

    @ApiOperation("风险评估实施指标---VTE风险评估率")
    @PostMapping("/riskVteAssesProbabilityExcle")
    public void riskVteAssesProbabilityExcle(HttpServletResponse response, @RequestBody List<IndicatorVteRiskVo> list) throws IOException {
        String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
        String fileName = "VTE风险评估率" + date;
        log.info("获取到的数据---"+list);
        UtilEasyExcle.export(response, fileName, fileName, list, IndicatorVteRiskVo.class);
    }

    @ApiOperation("风险评估实施指标---VTE中高危患者出血风险评估率")
    @PostMapping("/riskVteCrowningPatientExcle")
    public void riskVteCrowningPatientExcle(HttpServletResponse response, @RequestBody List<PatientMiddleHeightVo> list) throws IOException {
        String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
        String fileName = "VTE中高危患者出血风险评估率" + date;
        UtilEasyExcle.export(response, fileName, fileName, list, PatientMiddleHeightVo.class);
    }

    @ApiOperation("风险评估实施指标---VTE风险出院再评估率")
    @PostMapping("/riskVteDischargeDiagnosisExcle")
    public void riskVteDischargeDiagnosisExcle(HttpServletResponse response, @RequestBody List<PatientMiddleHeightVo> list) throws IOException {
        String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
        String fileName = "VTE风险出院再评估率" + date;
        UtilEasyExcle.export(response, fileName, fileName, list, PatientMiddleHeightVo.class);
    }

    @ApiOperation("预防措施实施指标---内科高危患者预防比例")
    @PostMapping("/preventHighInnerPatientExcle")
    public void preventHighInnerPatientExcle(HttpServletResponse response, @RequestBody List<HighRiskPatientVo> list) throws IOException {
        String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
        String fileName = "内科高危患者预防比例" + date;
        UtilEasyExcle.export(response, fileName, fileName, list, HighRiskPatientVo.class);
    }

    @ApiOperation("预防措施实施指标---外科中/高危患者的预防比例")
    @PostMapping("/preventMiddleAndHighOuterPatientExcle")
    public void preventMiddleAndHighOuterPatientExcle(HttpServletResponse response, @RequestBody List<HighRiskPatientVo> list) throws IOException {
        String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
        String fileName = "外科中/高危患者的预防比例" + date;
        UtilEasyExcle.export(response, fileName, fileName, list, HighRiskPatientVo.class);
    }

    @ApiOperation("结局相关指标---医院内非预期死亡发生率")
    @PostMapping("/endingUnanticipatedDeathExcle")
    public void endingUnanticipatedDeathExcle(HttpServletResponse response, @RequestBody List<DeathPatientVo> list) throws IOException {
        String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
        String fileName = "医院内非预期死亡发生率" + date;
        UtilEasyExcle.export(response, fileName, fileName, list, DeathPatientVo.class);
    }

    @ApiOperation("结局相关指标---医院内PTE死亡发生率")
    @PostMapping("/endingUnanticipatedDeathPieExcle")
    public void endingUnanticipatedDeathPieExcle(HttpServletResponse response, @RequestBody List<DeathPatientVo> list) throws IOException {
        String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
        String fileName = "医院内PTE死亡发生率" + date;
        UtilEasyExcle.export(response, fileName, fileName, list, DeathPatientVo.class);
    }

    @ApiOperation("结局相关指标---PTE导致死亡占死亡总数比率")
    @PostMapping("/endingDeathPieContrastSumExcle")
    public void endingDeathPieContrastSumExcle(HttpServletResponse response, @RequestBody List<DeathPatientVo> list) throws IOException {
        String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
        String fileName = "PTE导致死亡占死亡总数比率" + date;
        UtilEasyExcle.export(response, fileName, fileName, list, DeathPatientVo.class);
    }

    @ApiOperation("结局相关指标---PTE死亡患者中未预防的比例")
    @PostMapping("/endingDeathPieNoPreventSumExcle")
    public void endingDeathPieNoPreventSumExcle(HttpServletResponse response, @RequestBody List<DeathPatientVo> list) throws IOException {
        String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
        String fileName = "PTE死亡患者中未预防的比例" + date;
        UtilEasyExcle.export(response, fileName, fileName, list, DeathPatientVo.class);
    }

    @ApiOperation("诊治相关指标---PTE诊断成功率")
    @PostMapping("/endingPieSuccessExcle")
    public void endingPieSuccessExcle(HttpServletResponse response, @RequestBody List<DeathPatientVo> list) throws IOException {
        String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
        String fileName = "PTE诊断成功率" + date;
        UtilEasyExcle.export(response, fileName, fileName, list, DeathPatientVo.class);
    }







}
